using System;
using System.Diagnostics;

namespace OracleInternal.SqlAndPlsqlParser
{
	internal class PerformanceTimer : IDisposable
	{
		private Stopwatch m_vStopWatch;

		private string m_vOperationText;

		public PerformanceTimer(string opText)
		{
			m_vOperationText = opText;
			m_vStopWatch = new Stopwatch();
			m_vStopWatch.Start();
		}

		public void Dispose()
		{
			m_vStopWatch.Stop();
			long elapsedMilliseconds = m_vStopWatch.ElapsedMilliseconds;
			_ = $"Operation {m_vOperationText} took {elapsedMilliseconds / 1000} s. and {elapsedMilliseconds % 1000} ms.";
		}
	}
}
